﻿//Clase creada por Laura 26/06/10 Nos dice el index del player y del sniper

#region Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System.Linq;
using System.Text;
#endregion

namespace Engine
{
    /// <summary>
    /// Clase estatica que guarda que indice le corresponde al player y cual al sniper
    /// </summary>
    static public class JoysticksInfo
    {
        static public PlayerIndex playerIndex;
        static public PlayerIndex sniperIndex;
        static List<PlayerIndex> availableIndexes = new List<PlayerIndex>();
        static bool playerIndexAssigned;
        static bool sniperIndexAssigned;

        static public void Initialize()
        {
            playerIndexAssigned = false;
            sniperIndexAssigned = false;

            availableIndexes.Add(PlayerIndex.One);
            availableIndexes.Add(PlayerIndex.Two);
            availableIndexes.Add(PlayerIndex.Three);
            availableIndexes.Add(PlayerIndex.Four);
        }

        /// <summary>
        /// Si el indice dado es un indice disponible y el playerIndex no esta ya setiado,
        /// se lo setea.
        /// </summary>
        /// <param name="index"></param>
        static public void SetPlayerIndex(PlayerIndex index)
        {
            if (availableIndexes.Contains(index) && !playerIndexAssigned)
            {
                playerIndex = index;
                playerIndexAssigned = true;
                availableIndexes.Remove(index);
            }
        }

        /// <summary>
        /// Si el indice dado es un indice disponible y el sniperIndex no esta ya setiado,
        /// se lo setea.
        /// </summary>
        /// <param name="index"></param>
        static public void SetSniperIndex(PlayerIndex index)
        {
            if (availableIndexes.Contains(index) && !sniperIndexAssigned)
            {
                sniperIndex = index;
                sniperIndexAssigned = true;
                availableIndexes.Remove(index);
            }
        }
        static public bool PlayerIndexAssigned
        {
            get { return playerIndexAssigned; }
            set { playerIndexAssigned = value; }
        }
        static public bool SniperIndexAssigned
        {
            get { return sniperIndexAssigned; }
            set { sniperIndexAssigned = value; }
        }
        
    }
}
